home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / tcombo.exe / TCOMBOBX.H < prev    next >
C/C++ Source or Header  |  1992-11-18  |  7KB  |  208 lines

  1. /*************************************************************************/
  2. /*                                                                       */
  3. /* TCOMBOBX.H                                                            */
  4. /*                                                                       */
  5. /* Copyright (c) 1992, Vincent J. Dentice                                */
  6. /* All rights reserved                                                   */
  7. /*                                                                       */
  8. /* The TComboBox class is an extension to Borland International's Turbo  */
  9. /* Vision Applications Framework for DOS.  It provides a class that      */
  10. /* acts like a Combo Box in other graphical environments like Microsoft  */
  11. /* Windows and IBM OS/2.                                                 */
  12. /*                                                                       */
  13. /* It is designed to be with a TDialog class and a TCollection Class.    */
  14. /*                                                                       */
  15. /*                                                                       */
  16. /*   Date    Prg  Ver  Description                                       */
  17. /* --------  ---  ---  ------------------------------------------------- */
  18. /* 09/30/92  VJD  0.1  Initial module definition.                        */
  19. /* 11/16/92  VJD  0.2  Added streamability to the TComboBox classes.     */
  20. /*                     Rewrote header files to behave like original      */
  21. /*                     Turbo Vision header files.                        */
  22. /* 11/17/92  VJD  0.3  Added getData and setData functions to TComboBox, */
  23. /*                     and also added the missing dataSize function to   */
  24. /*                     TComboViewer.                                     */
  25. /*                                                                       */
  26. /*************************************************************************/
  27.  
  28. #if defined( Uses_TComboBox )
  29. #define Uses_TCollection
  30. #define Uses_TInputLine
  31. #define Uses_TView
  32. #endif
  33.  
  34. #if defined( Uses_TComboWindow )
  35. #define Uses_TComboViewer
  36. #define Uses_TWindow
  37. #endif
  38.  
  39. #if defined( Uses_TComboViewer )
  40. #define Uses_TCollection
  41. #define Uses_TEvent
  42. #define Uses_TListViewer
  43. #endif
  44.  
  45. #if defined( Uses_TCollection ) && !defined( __TCollection )
  46. #define INCLUDE_TV_H
  47. #endif
  48.  
  49. #if defined( Uses_TEvent ) && !defined( __TEvent)
  50. #define INCLUDE_TV_H
  51. #endif
  52.  
  53. #if defined( Uses_TInputLine ) && !defined( __TInputLine )
  54. #define INCLUDE_TV_H
  55. #endif
  56.  
  57. #if defined( Uses_TListViewer ) && !defined( __TListViewer )
  58. #define INCLUDE_TV_H
  59. #endif
  60.  
  61. #if defined( Uses_TView ) && !defined( __TView )
  62. #define INCLUDE_TV_H
  63. #endif
  64.  
  65. #if defined( Uses_TWindow ) && !defined( __TWindow )
  66. #define INCLUDE_TV_H
  67. #endif
  68.  
  69. #if defined( INCLUDE_TV_H )
  70. #include <tv.h>
  71. #endif
  72.  
  73.  
  74. #if defined( Uses_TComboBox ) && !defined( __TComboBox )
  75. #define __TComboBox
  76.  
  77. class TComboBox : public TView {
  78.    protected:
  79.       static char *icon;
  80.       TInputLine  *link;
  81.       TCollection *list;
  82.  
  83.    public:
  84.       TComboBox(const TRect&, TInputLine *, TCollection *);
  85.  
  86.       virtual ushort dataSize();
  87.       virtual void draw();
  88.       virtual void getData(void *);
  89.       TPalette& getPalette() const;
  90.       virtual void handleEvent(TEvent&);
  91.       virtual void newList(TCollection *);
  92.       virtual void setData(void *);
  93.       void shutDown();
  94.  
  95.    private:
  96.       virtual const char *streamableName() const
  97.      { return name; }
  98.  
  99.    protected:
  100.       TComboBox(StreamableInit);
  101.       virtual void write(opstream&);
  102.       virtual void *read(ipstream&);
  103.  
  104.    public:
  105.       static const char * const near name;
  106.       static TStreamable *build();
  107. };
  108.  
  109. inline ipstream& operator >> ( ipstream& is, TComboBox& cl )
  110.      { return is >> (TStreamable&)cl; }
  111. inline ipstream& operator >> ( ipstream& is, TComboBox*& cl )
  112.      { return is >> (void *&)cl; }
  113.  
  114. inline opstream& operator << ( opstream& os, TComboBox& cl )
  115.      { return os << (TStreamable&)cl; }
  116. inline opstream& operator << ( opstream& os, TComboBox* cl )
  117.      { return os << (TStreamable *)cl; }
  118.  
  119. #endif
  120.  
  121.  
  122.  
  123. #if defined( Uses_TComboViewer ) && !defined( __TComboViewer )
  124. #define __TComboViewer
  125.  
  126. class TComboViewer : public TListViewer {
  127.    public:
  128.       TCollection *list;
  129.  
  130.       TComboViewer(const TRect&, TCollection*, TScrollBar*);
  131.  
  132.       virtual ushort dataSize();
  133.       TPalette& getPalette() const;
  134.       virtual void getData(void *);
  135.       virtual void getText(char *, short, short);
  136.       virtual void handleEvent(TEvent&);
  137.       virtual void newList(TCollection *);
  138.       virtual void setData(void *);
  139.       void shutDown();
  140.  
  141.    private:
  142.       virtual const char *streamableName() const
  143.      { return name; }
  144.  
  145.    protected:
  146.       TComboViewer(StreamableInit);
  147.       virtual void write(opstream&);
  148.       virtual void *read(ipstream&);
  149.  
  150.    public:
  151.       static const char * const near name;
  152.       static TStreamable *build();
  153. };
  154.  
  155. inline ipstream& operator >> ( ipstream& is, TComboViewer& cl )
  156.      { return is >> (TStreamable&)cl; }
  157. inline ipstream& operator >> ( ipstream& is, TComboViewer*& cl )
  158.      { return is >> (void *&)cl; }
  159.  
  160. inline opstream& operator << ( opstream& os, TComboViewer& cl )
  161.      { return os << (TStreamable&)cl; }
  162. inline opstream& operator << ( opstream& os, TComboViewer* cl )
  163.      { return os << (TStreamable *)cl; }
  164.  
  165. #endif
  166.  
  167.  
  168. #if defined( Uses_TComboWindow ) && !defined( __TComboWindow )
  169. #define __TComboWindow
  170.  
  171. class TComboWindow : public TWindow {
  172.    protected:
  173.       TComboViewer *viewer;
  174.  
  175.    public:
  176.       TComboWindow(const TRect&, TCollection*);
  177.  
  178.       TPalette& getPalette() const;
  179.       void getSelection(char *);
  180.       virtual void handleEvent(TEvent&);
  181.       void setSelection(char *);
  182.  
  183.    private:
  184.       virtual const char *streamableName() const
  185.      { return name; }
  186.  
  187.    protected:
  188.       TComboWindow(StreamableInit);
  189.       virtual void write(opstream&);
  190.       virtual void *read(ipstream&);
  191.  
  192.    public:
  193.       static const char * const near name;
  194.       static TStreamable *build();
  195. };
  196.  
  197. inline ipstream& operator >> ( ipstream& is, TComboWindow& cl )
  198.      { return is >> (TStreamable&)cl; }
  199. inline ipstream& operator >> ( ipstream& is, TComboWindow*& cl )
  200.      { return is >> (void *&)cl; }
  201.  
  202. inline opstream& operator << ( opstream& os, TComboWindow& cl )
  203.      { return os << (TStreamable&)cl; }
  204. inline opstream& operator << ( opstream& os, TComboWindow* cl )
  205.      { return os << (TStreamable *)cl; }
  206.  
  207. #endif
  208.